.class public Lrexsee/device/RexseeWallpaper;
.super Ljava/lang/Object;
.source "RexseeWallpaper.java"

# interfaces
.implements Lrexsee/core/browser/clazz/JavascriptInterface;


# static fields
.field private static final INTERFACE_NAME:Ljava/lang/String; = "Wallpaper"

.field private static final WALLPAPER_WIDTH:I = 0x2d0


# instance fields
.field private final mBrowser:Lrexsee/core/browser/Browser;


# direct methods
.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 0
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 38
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 39
    iput-object p1, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    .line 40
    return-void
.end method

.method static synthetic access$0(Lrexsee/device/RexseeWallpaper;)Lrexsee/core/browser/Browser;
    .locals 1

    .prologue
    .line 36
    iget-object v0, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    return-object v0
.end method


# virtual methods
.method public clear()Z
    .locals 3

    .prologue
    .line 105
    iget-object v2, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {v2}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v2

    invoke-static {v2}, Landroid/app/WallpaperManager;->getInstance(Landroid/content/Context;)Landroid/app/WallpaperManager;

    move-result-object v1

    .line 107
    .local v1, "manager":Landroid/app/WallpaperManager;
    :try_start_0
    invoke-virtual {v1}, Landroid/app/WallpaperManager;->clear()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 108
    const/4 v2, 0x1

    .line 110
    :goto_0
    return v2

    .line 109
    :catch_0
    move-exception v0

    .line 110
    .local v0, "e":Ljava/lang/Exception;
    const/4 v2, 0x0

    goto :goto_0
.end method

.method public cropAndSet(Ljava/lang/String;)Z
    .locals 1
    .param p1, "path"    # Ljava/lang/String;

    .prologue
    const/4 v0, 0x0

    .line 44
    invoke-virtual {p0, p1, v0, v0}, Lrexsee/device/RexseeWallpaper;->cropAndSet(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z

    move-result v0

    return v0
.end method

.method public cropAndSet(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Z
    .locals 8
    .param p1, "path"    # Ljava/lang/String;
    .param p2, "successAlert"    # Ljava/lang/String;
    .param p3, "failAlert"    # Ljava/lang/String;

    .prologue
    .line 47
    const-string v6, "mounted"

    invoke-static {}, Landroid/os/Environment;->getExternalStorageState()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v6

    if-nez v6, :cond_0

    const/4 v6, 0x0

    .line 86
    :goto_0
    return v6

    .line 48
    :cond_0
    iget-object v6, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    const/4 v7, 0x0

    invoke-static {v6, p1, v7}, Lrexsee/core/style/RexseeDrawable;->getDrawable(Lrexsee/core/browser/Browser;Ljava/lang/String;Landroid/graphics/drawable/Drawable;)Landroid/graphics/drawable/Drawable;

    move-result-object v0

    .line 49
    .local v0, "drawable":Landroid/graphics/drawable/Drawable;
    if-nez v0, :cond_1

    const/4 v6, 0x0

    goto :goto_0

    .line 51
    :cond_1
    invoke-virtual {p1}, Ljava/lang/String;->toLowerCase()Ljava/lang/String;

    move-result-object v6

    const-string v7, "file:///android_asset"

    invoke-virtual {v6, v7}, Ljava/lang/String;->startsWith(Ljava/lang/String;)Z

    move-result v6

    if-eqz v6, :cond_4

    .line 52
    const-string v6, "."

    invoke-virtual {p1, v6}, Ljava/lang/String;->lastIndexOf(Ljava/lang/String;)I

    move-result v3

    .line 53
    .local v3, "pos":I
    if-gez v3, :cond_2

    const/4 v6, 0x0

    goto :goto_0

    .line 54
    :cond_2
    invoke-virtual {p1, v3}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v1

    .line 55
    .local v1, "ext":Ljava/lang/String;
    new-instance v6, Ljava/lang/StringBuilder;

    const-string v7, "file://"

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v7

    invoke-virtual {v7}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    const-string v7, "/tmpAssetImage"

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v4

    .line 56
    .local v4, "sdPath":Ljava/lang/String;
    iget-object v6, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {v6}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v6

    const/16 v7, 0x16

    invoke-virtual {p1, v7}, Ljava/lang/String;->substring(I)Ljava/lang/String;

    move-result-object v7

    invoke-static {v6, v7, v4}, Lrexsee/core/utilities/Utilities;->copyAssetToExternalStorage(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)Z

    move-result v6

    if-nez v6, :cond_3

    const/4 v6, 0x0

    goto :goto_0

    .line 57
    :cond_3
    iget-object v6, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {v6}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v6

    invoke-static {v6, v4}, Lrexsee/core/utilities/Utilities;->scanMediaStore(Landroid/content/Context;Ljava/lang/String;)V

    .line 61
    .end local v1    # "ext":Ljava/lang/String;
    .end local v3    # "pos":I
    :goto_1
    new-instance v6, Ljava/lang/StringBuilder;

    const-string v7, "file://"

    invoke-direct {v6, v7}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    invoke-static {}, Landroid/os/Environment;->getExternalStorageDirectory()Ljava/io/File;

    move-result-object v7

    invoke-virtual {v7}, Ljava/io/File;->getAbsolutePath()Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    const-string v7, "/tmpWallpaper.png"

    invoke-virtual {v6, v7}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v6

    invoke-virtual {v6}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    .line 62
    .local v5, "wallpaper":Ljava/lang/String;
    new-instance v2, Landroid/content/Intent;

    const-string v6, "com.android.camera.action.CROP"

    invoke-direct {v2, v6}, Landroid/content/Intent;-><init>(Ljava/lang/String;)V

    .line 63
    .local v2, "intent":Landroid/content/Intent;
    invoke-static {v4}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v6

    const-string v7, "image/*"

    invoke-virtual {v2, v6, v7}, Landroid/content/Intent;->setDataAndType(Landroid/net/Uri;Ljava/lang/String;)Landroid/content/Intent;

    .line 64
    const-string v6, "crop"

    const-string v7, "true"

    invoke-virtual {v2, v6, v7}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 65
    const-string v6, "scale"

    const-string v7, "true"

    invoke-virtual {v2, v6, v7}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 66
    const-string v6, "aspectX"

    const/4 v7, 0x1

    invoke-virtual {v2, v6, v7}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    .line 67
    const-string v6, "aspectY"

    const/4 v7, 0x1

    invoke-virtual {v2, v6, v7}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    .line 68
    const-string v6, "outputX"

    const/16 v7, 0x2d0

    invoke-virtual {v2, v6, v7}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    .line 69
    const-string v6, "outputY"

    const/16 v7, 0x2d0

    invoke-virtual {v2, v6, v7}, Landroid/content/Intent;->putExtra(Ljava/lang/String;I)Landroid/content/Intent;

    .line 70
    const-string v6, "return-data"

    const/4 v7, 0x0

    invoke-virtual {v2, v6, v7}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Z)Landroid/content/Intent;

    .line 71
    const-string v6, "output"

    invoke-static {v5}, Landroid/net/Uri;->parse(Ljava/lang/String;)Landroid/net/Uri;

    move-result-object v7

    invoke-virtual {v2, v6, v7}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Landroid/os/Parcelable;)Landroid/content/Intent;

    .line 72
    iget-object v6, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v6, v6, Lrexsee/core/browser/Browser;->activityResult:Lrexsee/core/browser/clazz/ActivityResult;

    new-instance v7, Lrexsee/device/RexseeWallpaper$1;

    invoke-direct {v7, p0, v5, p2, p3}, Lrexsee/device/RexseeWallpaper$1;-><init>(Lrexsee/device/RexseeWallpaper;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {v6, v2, v7}, Lrexsee/core/browser/clazz/ActivityResult;->start(Landroid/content/Intent;Lrexsee/core/browser/clazz/ActivityResult$ActivityResultListener;)V

    .line 86
    const/4 v6, 0x1

    goto/16 :goto_0

    .line 59
    .end local v2    # "intent":Landroid/content/Intent;
    .end local v4    # "sdPath":Ljava/lang/String;
    .end local v5    # "wallpaper":Ljava/lang/String;
    :cond_4
    move-object v4, p1

    .restart local v4    # "sdPath":Ljava/lang/String;
    goto :goto_1
.end method

.method public getDesiredMinimumSize()Ljava/lang/String;
    .locals 6

    .prologue
    .line 114
    iget-object v4, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {v4}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v4

    invoke-static {v4}, Landroid/app/WallpaperManager;->getInstance(Landroid/content/Context;)Landroid/app/WallpaperManager;

    move-result-object v1

    .line 115
    .local v1, "manager":Landroid/app/WallpaperManager;
    invoke-virtual {v1}, Landroid/app/WallpaperManager;->getDesiredMinimumWidth()I

    move-result v3

    .line 116
    .local v3, "w":I
    if-gez v3, :cond_0

    iget-object v4, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v4, v4, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget v3, v4, Lrexsee/core/application/RexseeApplication;->screenWidth:I

    .line 117
    :cond_0
    invoke-virtual {v1}, Landroid/app/WallpaperManager;->getDesiredMinimumHeight()I

    move-result v0

    .line 118
    .local v0, "h":I
    if-gez v0, :cond_1

    iget-object v4, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v4, v4, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget v0, v4, Lrexsee/core/application/RexseeApplication;->screenHeight:I

    .line 119
    :cond_1
    const-string v2, "{"

    .line 120
    .local v2, "rtn":Ljava/lang/String;
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-static {v2}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v5, "\"width\":"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4, v3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 121
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-static {v2}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v5, ",\"height\":"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 122
    new-instance v4, Ljava/lang/StringBuilder;

    invoke-static {v2}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v5

    invoke-direct {v4, v5}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v5, "}"

    invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v4

    invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    .line 123
    return-object v2
.end method

.method public getInheritInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 0
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 27
    return-object p0
.end method

.method public getInterfaceName()Ljava/lang/String;
    .locals 2

    .prologue
    .line 23
    new-instance v0, Ljava/lang/StringBuilder;

    iget-object v1, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v1, v1, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v1, v1, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v1

    invoke-direct {v0, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v1, "Wallpaper"

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    return-object v0
.end method

.method public getNewInterface(Lrexsee/core/browser/Browser;)Lrexsee/core/browser/clazz/JavascriptInterface;
    .locals 0
    .param p1, "childBrowser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 31
    return-object p0
.end method

.method public set(Ljava/lang/String;)Z
    .locals 6
    .param p1, "path"    # Ljava/lang/String;

    .prologue
    const/4 v5, 0x0

    .line 89
    iget-object v3, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    const/4 v4, 0x0

    invoke-static {v3, p1, v4}, Lrexsee/core/style/RexseeDrawable;->getDrawable(Lrexsee/core/browser/Browser;Ljava/lang/String;Landroid/graphics/drawable/Drawable;)Landroid/graphics/drawable/Drawable;

    move-result-object v0

    .line 90
    .local v0, "drawable":Landroid/graphics/drawable/Drawable;
    if-nez v0, :cond_0

    move v3, v5

    .line 101
    .end local v0    # "drawable":Landroid/graphics/drawable/Drawable;
    :goto_0
    return v3

    .line 91
    .restart local v0    # "drawable":Landroid/graphics/drawable/Drawable;
    :cond_0
    instance-of v3, v0, Landroid/graphics/drawable/BitmapDrawable;

    if-eqz v3, :cond_1

    .line 92
    iget-object v3, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {v3}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v3

    invoke-static {v3}, Landroid/app/WallpaperManager;->getInstance(Landroid/content/Context;)Landroid/app/WallpaperManager;

    move-result-object v2

    .line 94
    .local v2, "manager":Landroid/app/WallpaperManager;
    :try_start_0
    check-cast v0, Landroid/graphics/drawable/BitmapDrawable;

    .end local v0    # "drawable":Landroid/graphics/drawable/Drawable;
    invoke-virtual {v0}, Landroid/graphics/drawable/BitmapDrawable;->getBitmap()Landroid/graphics/Bitmap;

    move-result-object v3

    invoke-virtual {v2, v3}, Landroid/app/WallpaperManager;->setBitmap(Landroid/graphics/Bitmap;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 95
    const/4 v3, 0x1

    goto :goto_0

    .line 96
    :catch_0
    move-exception v3

    move-object v1, v3

    .line 97
    .local v1, "e":Ljava/lang/Exception;
    iget-object v3, p0, Lrexsee/device/RexseeWallpaper;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {p0}, Lrexsee/device/RexseeWallpaper;->getInterfaceName()Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4, v1}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/Exception;)V

    move v3, v5

    .line 98
    goto :goto_0

    .end local v1    # "e":Ljava/lang/Exception;
    .end local v2    # "manager":Landroid/app/WallpaperManager;
    .restart local v0    # "drawable":Landroid/graphics/drawable/Drawable;
    :cond_1
    move v3, v5

    .line 101
    goto :goto_0
.end method
